package com.wisezone.HomeWork.home0217;

import com.wisezone.demo0217.Person;

public class Test {
    public void test3()throws Exception{
        //1.调用运行时类本身的.class属性
        Class clazz1= Person.class;
        System.out.println(clazz1.getName());
        Class clazz2= Person.class;
        System.out.println(clazz2.getName());
        //2.通过运行时类的对象来获取
        Person person = new Person();
        Class clazz3 = person.getClass();
        System.out.println(clazz3.getName());
        //3.通过Class的静态方法forName()
        Class clazz4 = Class.forName("com.wisezone.HomeWork.home0217");
        Person p = (Person) clazz4.newInstance();
        System.out.println(clazz4);
        //4.(了解)通过类的加载器来获取Class的实例
        ClassLoader classLoader = this.getClass().getClassLoader();
        Class clazz5 = classLoader.loadClass("com.wisezone.HomeWork.home0216");
    }
}
